package mysql

import "gorm.io/gorm"

type RealAuth struct {
	gorm.Model
	UserId   int64  `gorm:"column:user_id;type:int(11);not null;comment:用户ID"`
	RealName string `gorm:"column:real_name;type:varchar(20);not null;comment:真实姓名"`
	IdCard   string `gorm:"column:id_card;type:varchar(20);not null;comment:身份证号"`
}

// 添加实名认证信息
func (r *RealAuth) CreateRealAuth() error {
	return mysqlClient.Create(&r).Error
}

// 获取用户ID信息
func (r *RealAuth) GetUserIdInfo() error {
	return mysqlClient.Where("user_id = ?", r.UserId).First(&r).Error
}

// 获取身份证信息
func (r *RealAuth) GetIdCardInfo() error {
	return mysqlClient.Where("id_card = ?", r.IdCard).First(&r).Error
}
